package cn.com.sueframe.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
/**
 * //�Զ����ʻ���ǩ
 * @author anler
 * Create Jul 7, 2012
 */
public class I18n extends TagSupport {
    /**
	 * 
	 */
	private static final long serialVersionUID = -5097375698310818889L;
	private String english;//����������
    private String chinese;//��������
    private String country;//�����Ϣ
    private PageContext pageContext;
    private JspWriter out;
	@Override
	public int doEndTag() throws JspException {
		if(english == null){
			english = "";
		}
		if(chinese == null){
			chinese = "";
		}
		try{
			if("CN".equals(country)){
				out.write(chinese);
			}else{
				out.write(english);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return EVAL_PAGE;
	}

	@Override
	public int doStartTag() throws JspException {
		out = pageContext.getOut();
		Object tempCountryObject = pageContext.getAttribute("ceswich",PageContext.SESSION_SCOPE);
		if(tempCountryObject == null){
			tempCountryObject = "";
		}
		country = String.valueOf(tempCountryObject);
		return EVAL_PAGE;
	}
	

	public String getEnglish() {
		return english;
	}

	public void setEnglish(String english) {
		this.english = english;
	}

	public String getChinese() {
		return chinese;
	}

	public void setChinese(String chinese) {
		this.chinese = chinese;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public PageContext getPageContext() {
		return pageContext;
	}

	public void setPageContext(PageContext pageContext) {
		this.pageContext = pageContext;
	}
}
